package com.itqhy.pojo;


import org.springframework.stereotype.Component;

@Component("cartItem")
public class CartItem {

    private Product product; //商品对象
    private Integer count; // 购买数量
    private Double total; //购买小计

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Double getTotal() {
        return product.getPrice()*getCount();
    }

    public CartItem(Product product, Integer count) {
        this.product = product;
        this.count = count;
    }

    public CartItem() {

    }

    @Override
    public String toString() {
        return "CartItem{" +
                "product=" + product +
                ", count=" + count +
                ", total=" + total +
                '}';
    }
}
